<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Taped Login Form Flat Responsive Widget Template::w3layouts</title>
<!-- Meta tag Keywords -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="keywords" content="taped login form Widget a Flat Responsive Widget,Login form widgets, Sign up Web forms , Login signup Responsive web form,Flat Pricing table,Flat Drop downs,Registration Forms,News letter Forms,Elements" />
<script type="application/x-javascript"> 
addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
function hideURLbar(){ window.scrollTo(0,1); } 
</script>
<style>
body {
background: url(${pageContext.request.contextPath}/dist/img/ship.jpg) no-repeat;
background-size: 100% 100%;
}
</style>
<!-- Meta tag Keywords -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/style2.css" type="text/css" media="all" /><!-- Style-CSS -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/font-awesome.css" type="text/css" media="all" />

</head>
<body data-vide-bg="video/ship">
<section class="login-maintop">
	<div class="login-main" >
		<% Cookie[]cookies=request.getCookies(); 
      String uname="";
      String upwd="";
      String checked="";
      if(null != cookies){
    	  for(Cookie c:cookies){
    		  //取出我需要的三个值,判断key
    		  if(c.getName().equals("adminAccount")){
    			  uname=c.getValue();
    		  }else if(c.getName().equals("adminPwd")){
    			  upwd=c.getValue();
    		  }else if(c.getName().equals("checked")){
    			  checked=c.getValue();
    		  }
    	  }
    	  //把值保存在作用域
    	  pageContext.setAttribute("username", uname);
    	  pageContext.setAttribute("userpwd", upwd);
    	  pageContext.setAttribute("checked", checked);
      }
      %>
		<header><h1>欢迎来到EduSystem管理系统</h1></header>
		<div class="login-form">
			<h2>请登录</h2>
			<form action="${pageContext.request.contextPath}/EduControllerByLu?op=adminLogin" method="post">
				<span><i class="fa fa-user-o" aria-hidden="true"></i></span>
				<input type="text" name="username" placeholder="请输入账号" required value="${username}">
				<span><i class="fa fa-unlock-alt" aria-hidden="true"></i></span>
				<input type="password" name="password" placeholder="请输入密码" required value="${userpwd}">
				<span><i class="fa fa-user-o" aria-hidden="true"></i></span>
				<input type="text" name="checkImg" placeholder="请输入验证码" required id="checkImg">
				<div id="getimg">
				</div>
				<P></P>
				<c:choose>
				<c:when test="${checked eq 'checked'}">
				<input type="checkbox" name="remberme" value="ischecked" checked="checked" style=" height: 20px; width: 20px;" /> <font size="4px" style="color: white;">记住密码</font>
				</c:when> 
            <c:otherwise>
            <input type="checkbox" name="remberme" value="ischecked" style=" height: 20px; width: 20px;" /> <font size="4px" style="color: white;">记住密码</font>
				  </c:otherwise>
            </c:choose> <P></P>
				<input type="submit" value="登录" id="loginBtn">
			</form>
			<div class="login-password">
				<span><a href="#">忘记密码</a></span>
			</div>
		</div>
		<!--footer-->
		<div class="footer">
			<p>&copy; 2020 中 软 四 期 二 阶 段 项目 | by 陆亮 郑智涵 邓红学 陆海 苟瑜霞</p>
		</div>
		<!--//footer-->
	</div>
</section>
<script type="text/javascript" src="${pageContext.request.contextPath}/dist/js/jquery-2.1.4.min.js"></script>
<script src="${pageContext.request.contextPath}/dist/js/jquery.vide.min.js"></script>
<script src="${pageContext.request.contextPath}/dist/js/jquery.min.js"></script>
<!-- 引入 echarts.js -->
    <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</body>
<script type="text/javascript">
$(function(){
	//获取焦点事件
	$("#checkImg").focus(function(){
		showImg();
	})
	
	$("$loginBtn").submit(function(){
		$.get("${pageContext.request.contextPath}/EduControllerByLu",{op:"getImgText"},function(data){
			alert(data);
			if($("#checkImg").val() == data){
				return true;
			}else{
				return false;
			}
		})
	})
	
	
	$(document).on("click","#changeImg",function(){
		showImg()
	})
})

function showImg(){
	$("#getimg").empty(); 
	$("#getimg").append("<a href='#' id='changeImg' onclick='changeImgs()'><img src='${pageContext.request.contextPath}/EduControllerByLu?op=getImg' style='width:350px;height:180px;'></a>");

}

/* function changeImgs(){
	showImg();
} */

</script>
</html>